From: Jens Axboe Date: Sun, 12 Sep 2021 12:45:07 +0000 (-0600) Subject: io_uring: ensure symmetry in handling iter types in loop_rw_iter() X-Git-Tag: archive/raspbian/5.14.6-2+rpi1^2~13 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks:///%22http:/www.example.com/cgi/%22https:/%22bookmarks:/?a=commitdiff_plain;h=8b14a6e8293929cffcd4ea80e36cd26af1f84c8a;p=linux.git io_uring: ensure symmetry in handling iter types in loop_rw_iter() Origin: https://git.kernel.org/linus/16c8d2df7ec0eed31b7d3b61cb13206a7fb930cc Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2021-41073 When setting up the next segment, we check what type the iter is and handle it accordingly. However, when incrementing and processed amount we do not, and both iter advance and addr/len are adjusted, regardless of type. Split the increment side just like we do on the setup side. Fixes: 4017eb91a9e7 ("io_uring: make loop_rw_iter() use original user supplied pointers") Cc: stable@vger.kernel.org Reported-by: Valentina Palmiotti Reviewed-by: Pavel Begunkov Signed-off-by: Jens Axboe Gbp-Pq: Topic bugfix/all Gbp-Pq: Name io_uring-ensure-symmetry-in-handling-iter-types-in-l.patch --- diff --git a/fs/io_uring.c b/fs/io_uring.c index c5d4638f6d7..e5698b3beb0 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -3107,12 +3107,15 @@ static ssize_t loop_rw_iter(int rw, struct io_kiocb *req, struct iov_iter *iter) ret = nr; break; } + if (!iov_iter_is_bvec(iter)) { + iov_iter_advance(iter, nr); + } else { + req->rw.len -= nr; + req->rw.addr += nr; + } ret += nr; if (nr != iovec.iov_len) break; - req->rw.len -= nr; - req->rw.addr += nr; - iov_iter_advance(iter, nr); } return ret;